<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link href="../css/own.css" rel="stylesheet" />
		<link rel="stylesheet" href="../css/mui.picker.min.css" />
		<link rel="stylesheet" href="../css/mui.picker.min.css" type="text/css" charset="utf-8" />
		<style type="text/css">
			.st_cot {
				font-size: 0.65rem;
				line-height: 0.7rem;
				background: #FFFFFF;
				border: none;
				width: 70%;
				color: #50CEBD;
			}


			.mui-table-view-cell {
				line-height: 1.4rem;
			}

			.mui-table-view-cell.mui-active {
				background: transparent;
			}

			.value-holder {
				color: #333333;
				padding-left: 0.3rem;
				font-size: 0.65rem;
			}

			#div_button_house {
				background: #007aff;
				color: #ffffff;
				font-size: 0.8rem;
				padding: 0.5rem 1rem;
				border-radius: 0.7rem;
				margin: 1rem 0.5rem 0.8rem 0rem;
				text-align: center;
			}

			.mui-table-view-cell span {
				font-size: 0.7rem;
			}

			.zt_size {
				font-size: 0.75rem;
				margin-left: 9%;
			}

			span.zt_size {
				font-size: 0.75rem;
			}

			#zt_span {
				height: 1.6rem;
				display: inline-block;
				background: #007aff;
				color: #ffffff;
				font-size: 0.65rem;
				padding: 0 0.1rem;
				border-radius: 0.2rem;
				line-height: 1.8rem;
				margin-left: 1rem;
				width: 4rem;
				text-align: center;
			}

			input.zb_ys {
				color: #333333;
				height: 1.8rem;
				padding: 0rem 0rem;
				margin: 0rem;
				font-size: 0.65rem;
				text-align: center;

			}
			.sydbg {
				background-color: #FFFFFF;
			}
			.fh{
				width: 1rem;
				height: 1rem;
				padding-top: 0.3rem;
				
			}
			
			.fhkx{
				width: 1rem;
				height: 1rem;
				padding-top: 0.3rem;
				margin-left: 0.75rem;
				
			}
		</style>
	</head>

	<body>
		<header class="mui-bar own-mui-bar-nav own-main-background-color ">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left "></a>
			<h1 class="mui-title">试验检测</h1>
			<span class="mui-icon mui-icon-plusempty mui-icon-right-nav mui-pull-right" id="addsyd" style="font-size: 0.7rem;line-height: 1.3rem;color: #FFFFFF">新增试验点</span>
		</header>
		<div class="mui-content">
			<ul class="mui-table-view " style="font-size: 0.65rem;">
				<li class="mui-table-view-cell">
					<span>单元工程编号:</span>
					<div id="uproj_num" class="value-holder mui-inline"></div>
				</li>

				<li class="mui-table-view-cell">
					<span class="zt_size">层号:</span>
					<div id="cenghao" class="value-holder mui-inline"></div>
				</li>
				<li class="mui-table-view-cell">
					<div class="mui-inline zt_size">相对密度:</div>
					<div class="value-holder mui-inline">
						<input id="md" type="number" style="color: #333333;width: 40%;height:1rem;padding:0rem 0rem;margin:0rem ;border: none;font-size: 0.65rem;"
						 placeholder="请输入密度" />
					</div>
					
					<img src="../img/dydy.png" class="fh" id="mdimg">

				</li>

				<li class="mui-table-view-cell">
					<div class="mui-inline zt_size">孔隙率:</div>
					<div class="value-holder mui-inline">
						<input id="kxl" type="number" style="color: #333333;width: 60%;height:1rem;padding:0rem 0rem;margin:0rem ;border: none;font-size: 0.65rem;"
						 placeholder="请输入孔隙率" />
					</div>
                   <img src="../img/dydy.png" class="fhkx" id="kxlimg">
				</li>
				<li class="mui-table-view-cell" id="a_ctime">
					<a class="mui-navigate-right">
						<span class="zt_size">检测日期:</span>
						<span id="ctime" class="value-holder mui-inline"></span>
					</a>
				</li>

			</ul>

			<div id="div_button_house">保存</div>

			<div class="sydbg">
				<ul class="mui-table-view" id="dianlist">
					<!-- <li class="mui-table-view-cell" onclick="tzcanglist('B-BE')">
						<div class="zs_content_bg mui-clearfix" style="font-size: 0.6rem;margin-top: 0.3rem;">
							<div class="mui-pull-left">相对密度：<span>B-BE</span></div>
							<div class="mui-pull-right" style="width: 6rem;">孔隙率：<span>0.27</span></div>
						</div>
						<div class="zs_content_bg mui-clearfix" style="font-size: 0.6rem;margin-top: 0.3rem;">
							<div class="mui-pull-left">北坐标：<span>B-BE</span></div>
							<div class="mui-pull-right mui-ellipsis" style="width: 6rem;">东坐标：<span>0.27</span></div>
						</div>
						<div class="mui-pull-right"><a class="mui-navigate-right"></a></div>
					</li> -->
					
				</ul>
			</div>
		</div>

		<script src="../js/mui.min.js"></script>
		<script src="../js/common.js"></script>
		<script src="../js/jquery-1.7.2.min.js"></script>
		<script src="../js/mui.picker.min.js"></script>
		<script src="../js/mui.picker.min.js"></script>

		<script type="text/javascript">
			mui.init();

			var indexview = null;

			var syid = null;
			var uid = null;
			var layer = null;
			var indexNum = null;




			mui.plusReady(function() {

				indexview = plus.webview.currentWebview();

				syid = indexview.data;
				uid = indexview.path;
				layer = indexview.thParam;

				$('#uproj_num').text(uid);
				$('#cenghao').text(layer);

				querycdinfo(); //查询试验检测数据
                
				querysylist(); //查询试验点列表
				
				document.getElementById('div_button_house').addEventListener('tap', function() {
					savedata();
				});

				document.getElementById('addsyd').addEventListener('tap', function() {
					gotoSumPage('experiment_spot.html?' + '' + '?' + uid + '?' + layer);
				})
                document.getElementById('mdimg').addEventListener('tap',function () {
						  if(this.src.indexOf('dydy') == -1){
							    $("#mdimg").attr("src", '../img/dydy.png');
						  }else{
							   $("#mdimg").attr("src",'../img/xydy.png');
						  }
                })
				
				document.getElementById('kxlimg').addEventListener('tap',function () {
						  if(this.src.indexOf('dydy') == -1){
							  $("#kxlimg").attr("src", '../img/dydy.png');
						  }else{
							   $("#kxlimg").attr("src",'../img/xydy.png');
						  }
				})
        

				addEt();
			});

			function querycdinfo() {
				var params = {
					'node': localStorage.getItem('node'), //节点编号
					'uid': uid,
					'layer': layer,
				};
				mpms_ajax(params, 'getPieceCheck', function(data) {
					if (data.status == '0') {
						if (!isNull(data.data)) {
							syid = data.data.id;
							let dr = data.data.dr;
							if(!isNull(dr)){
								$('#md').val(dr.slice(1));
								//复值图片
								if(dr.slice(0,1) == '≥'){
									 $("#mdimg").attr("src", '../img/dydy.png');
								}else{
									 $("#mdimg").attr("src",'../img/xydy.png');
								}
							}
							
							let kxl = data.data.kxl;
							if(!isNull(kxl)){
								$('#kxl').val(kxl.slice(1));
								//复值图片
								if(kxl.slice(0,1) == '≥'){
									 $("#kxlimg").attr("src", '../img/dydy.png');
								}else{
									 $("#kxlimg").attr("src",'../img/xydy.png');
								}
							}
							$('#ctime').text(getdate(data.data.ctime));
						}
					} else {
						mui.toast(data.msg);
					}
				});
			}

			function savedata() {
				getPagetoken();
				var dr = $('#md').val();
				var kxl = $('#kxl').val();
				var ctime = $('#ctime').text();

				// if (isNull(dr)) {
				// 	mui.toast('请输入设计相对密度');
				// 	return;
				// }
				// if (isNull(kxl)) {
				// 	mui.toast('请输入设计孔隙率');
				// 	return;
				// }
				if (isNull(dr) && isNull(kxl)) {
					mui.toast('请输入相对密度或者孔隙率');
					return;
				}
				if (isNull(ctime)) {
					mui.toast('请选择检测日期');
					return;
				}
				//相对密度大于等于符号
				if(!isNull(dr)){
					if($('#mdimg')[0].src.indexOf('dydy') != -1){
						dr='≥'+dr;
					}else{
						dr='≤'+dr;
					}
				}
				
				//孔隙率大于等于符号
				if(!isNull(kxl)){
					if($('#kxlimg')[0].src.indexOf('dydy') != -1){
						kxl='≥'+kxl;
					}else{
						kxl='≤'+kxl;
					}
				}
				
				if(isNull(syid)){
					syid = '';
				}
				var params = {
					'id': syid,
					'node': localStorage.getItem('node'), //节点编号
					'uid': uid,
					'layer': layer,
					'dr': dr,
					'kxl': kxl,
					'ctime': ctime
				};
            

				mpms_ajax(params, 'pieceCheck', function(data) {

					if (data.status == '0') {
						mui.toast('保存成功');
					} else {
						mui.toast(data.msg);
					}
				});

			}

			//时间选择
			function addEt() {
				var option = {
					"type": "date",
					"beginYear": "1980",
					"endYear": "2030"
				};
				var picker = new mui.DtPicker(option);
				document.getElementById('a_ctime').addEventListener('tap', function() {
					picker.show(function(rs) {
						document.getElementById('ctime').innerHTML = rs.text;
					});
				});
			}


           function querysylist() {
           	var params = {
           		'node': localStorage.getItem('node'), //节点编号
           		'uid': uid,
           		'layer': layer,
           	};
           	mpms_ajax(params, 'getPieceCheckPosList', function(data) {
           		if (data.status == '0') {
					$('#dianlist').empty();
           			if (!isNull(data.list)) {
						for(let i=0;i<data.list.length;i++) {
						   setItems(data.list[i]);
						}
           			}
           		} else {
           			mui.toast(data.msg);
           		}
           	});
           }

			function setItems(info) {
				var htmls = '';
					htmls +='<li class="mui-table-view-cell" onclick="tzcanglist(\'' + info.id + '\')">';
					htmls +='<div class="zs_content_bg mui-clearfix" style="font-size: 0.6rem;margin-top: 0.3rem;"><div class="mui-pull-left">相对密度：<span>'+info.dr+'</span></div>';
					htmls +='<div class="mui-pull-right" style="width: 8rem;">北坐标：<span>'+info.n+'</span></div></div>';
				    htmls +='<div class="zs_content_bg mui-clearfix" style="font-size: 0.6rem;margin-top: 0.3rem;"><div class="mui-pull-left">孔隙率：<span>'+info.kxl+'</span></div>';
					htmls +='<div class="mui-pull-right mui-ellipsis" style="width: 8rem;">东坐标：<span>'+info.e+'</span></div></div><div class="mui-pull-right"><a class="mui-navigate-right"></a></div></li>';
				   $('#dianlist').append(htmls);
			}
		function tzcanglist(id){
			// gotoSumPage('experiment_spot.html?' + id + '?' + uid + '?' + layer);
		}	
		</script>
	</body>

</html>
